package com.example.library.mapper;

import com.example.library.entity.Appointment;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.example.library.entity.AppointmentDto;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * <p>
 *  Mapper 接口
 * </p>
 *
 * @author 胡绍杆
 * @since 2022-06-16
 */
public interface AppointmentMapper extends BaseMapper<Appointment> {

    @Select("SELECT DISTINCT appointment_id as appointmentId,bookname,author,appointment_time as appointmentTime,appointment_state as appointmentState " +
            "FROM t_appointment a LEFT JOIN t_book b ON a.isbn = b.isbn " +
            "where a.appointment_state in (1,2,3) and a.account = #{account} "+
            "ORDER BY appointment_time DESC " +
            "LIMIT #{pageNum} , #{pageSize}")
    List<AppointmentDto> getAppointmentByAccount(@Param("account") String account,@Param("pageNum") Integer pageNum,
                                                 @Param("pageSize") Integer pageSize);
}
